<template>
	<view class="">
		<!--#ifdef APP -->
		<u-sticky offset-top="0">
			<!--#endif-->
			<view class="bg">
				<u-tabs :list="list" @click="click" :current="current" itemStyle="width:33%; padding:10px 0;height: 28px;"></u-tabs>
			</view>
			<!--#ifdef APP -->
		</u-sticky>
		<!--#endif-->
		<mescroll-body ref="mescrollRef" height="60%" @init="mescrollInit" @up="upCallback" @down="downCallback">
			<telbook type="list" :list="InfoList" @init="getdata"></telbook>
		</mescroll-body>
		<zero-back-top :scrollTop="scrollTop"></zero-back-top>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import telbook from "@/components/telbook.vue"
	export default {
		mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
		components: {
			telbook,
		},
		data() {
			return {
				id: '',
				list: [{
					name: 'Myfollwed',
				}, {
					name: 'Viewed Record',
				}, {
					name: 'My Directory'
				}],
				sort: 'collect',
				InfoList: [],
				scrollTop: 0,
				index:0,
				current:0
			}
		},
		onLoad(e) {
			this.id = e.id
			this.type = e.type
			this.index = e.index - 1
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop
		},
		methods: {
			downCallback() {
				// 下拉回调
				this.current = this.index
				if (this.index == 0) {
					this.sort = 'collect'
				}
				if (this.index == 1) {
					this.sort = 'browse'
				}
				if (this.index == 2) {
					this.sort = 'mobile'
				}
				this.getdata()
			},
			upCallback() {
				// 上拉回调
				return
			},
			click(item) {
				this.current = item.index
				console.log('item', item);
				if (item.index == 0) {
					this.sort = 'collect'
				}
				if (item.index == 1) {
					this.sort = 'browse'
				}
				if (item.index == 2) {
					this.sort = 'mobile'
				}
				this.getdata()
			},
			getdata() {
				const params = {
					map: 'applet_mobile_record_list',
					type:this.sort
				}
				this.$Request({
					method: 'GET',
					data: params
				}).then(res => {
					if (res.data.ec == 200) {
						console.log(res)
						this.InfoList = res.data.data
						this.mescroll.endSuccess(res.data.data.length);
					} else {
						this.mescroll.endSuccess(0);
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f4f4f4;
	}

	.bg {
		background-color: #fff;
	}
</style>
